package com.lagou.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Calendar;

@Controller
public class LoginController {

    /**
     * 浏览器输入localhost:8080时打开登录页
     * @param model
     * @return
     */
    @RequestMapping("/")
    public String index(Model model){
        model.addAttribute("currentYear", Calendar.getInstance().get(Calendar.YEAR));
        return "login";
    }

    /**
     * 切换中英文时，登录页文字切换中英文
     * @param model
     * @return
     */
    @RequestMapping("/toLoginPage")
    public String toLoginPage(Model model){
        model.addAttribute("currentYear", Calendar.getInstance().get(Calendar.YEAR));
        return "login";
    }

    /**
     * 登录成功，重定向至我的博客页面
     * @param model
     * @return
     */
    @RequestMapping("/login")
    public String login(Model model){
        System.out.println("进入列表页");
        return "redirect:article/list";
    }
}
